<?php

if($data['ep']['detail']['nct']!=''){

	$str['web']=embed_nct($data['ep']['detail']['nct']);
	$str['mobile']=$str['web'];
}
else
if($data['ep']['detail']['picasa']!=''){
		$str=embed_picasa($data['ep']['detail']['picasa']);
		if($data['ep']['detail']['4share']!='' && $data['ep']['detail']['4share']!=0){
		
		$str['mobile'][]=link_forshare($data['ep']['detail']['4share']);
		}
		//Generate mobile embed
		$str['mobile']=embed_mobile($str['mobile']);
	
}else
if($data['ep']['detail']['4share']!=''){
	$str['web']=embed_forshare($data['ep']['detail']['4share']);
	$str['mobile']=$str['web'];
}

?>
<div class="wrapMain">
	<div id="row">
   <div id="anime_view" class="col-md-8"> 
        <ul class="breadcrumb" style="background-color:#fff">
        	<li><a href="<?php echo HOME ?>"><i class="fa fa-home"></i></a></li>
            <li><a href="<?php echo HOME ?>truyen">Anime</a></li>
             <li><?php echo $data['name']; ?></li>
               <li><?php echo $data['ep']['title']; ?></li>
    </ul>
            <!-- START TRUYEN DE CU -->
        <div class="panel panel-default">
        <div class="panel-heading">
        	<h1 style="padding:5px; font-size:16px; font-weight:normal">Bạn Đang xem anime <?php echo $data['name']; ?>  <?php echo $data['ep']['title']; ?> Vietsub Online</h1>
        </div>
  		<div class="panel-body">
  		           <div class="row">
					<?php echo $str['web'];?>
  		
        <Br/>
                
           
           <div class="btn-group">
  <button type="button" class="btn btn-default" id="full_screen"><span class="glyphicon glyphicon-fullscreen"></span> Phóng To</button>
  <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-warning-sign"></span> Báo Lỗi</button>
  <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-bookmark"></span> BookMark</button>
</div>
	<!-- Start tab ep -->
 <script>
 $( "#full_screen" ).click(function() {
  	
	var aclass=$('#anime_view').attr("class");
	if(aclass=='col-md-8'){
		$('#anime_view').removeClass("col-md-8").addClass("col-md-12");
	}else{
		$('#anime_view').removeClass("col-md-12").addClass("col-md-8");
	}
	
});
 </script>
 
<div class="clearfix"></div>


   </div> <!-- End of row -->
	</div> <!-- End of panel body -->
     <div class="panel-footer user_upload_info">
 	<!-- User upload information -->
    <img src="http://localhost/anime24h.vn/images/upload/nzr6bry7mfkckw.jpg" class="img-rounded pull-left" style="max-width:50px ; margin-right:10px" />
 		<div class="upload_user"><a href=""><span class="user_level">[ ADMIN ] </span>Bánh Mì Khét</a></div>
 			     <div class="upload_time">Đăng cách đây 4 ngày</div>
                 <div class="upload_user_home"><ul class="nav nav-pills">
                                <li> <a href="http://mong.vn/blog/user/levan.van.399"><i class="fa fa-home"></i> HOME           </a>  </li>
                                <li> <a href="http://mong.vn/video/user/levan.van.399"><i class="fa fa-facebook"></i> FACEBOOK </a> </li>
                                 <li><a href="http://mong.vn/truyen/user/levan.van.399"><i class="fa fa-envelope"></i> MESSAGE</a> </li>
                                         
                                        </ul></div>
        <div class="clearfix"></div>
 	</div> <!-- End panel footer-->
		</div> <!-- End of panel -->





    <!-- Start tab -ep fs -->
       <div class="panel panel-default">
 		 <div class="panel-body">
 <style>
.fansub_ep .nav > li > a {
position: relative;display: block;padding: 3px 10px;}
</style> 
<?php
$str=render_fansub_ep($data['data']);
echo $str;
 ?> 
 <script>
 $(document).ready(function(){
	 //ACTIVE TAB
     $('.nav-tabs a[href="#fansub' +<?php echo $data['ep']['fansub_id']; ?> + '"]').tab('show');
	 //ACTIVE LINK
	 $('#ep<?php echo $_GET['id'] ?>').addClass('active');
});


 </script>
 </div> <!-- End panel body -->

 </div> <!-- End panel -->
 <!-- End tab ep -->



        <!-- End truyen de cu -->
        <div class="panel panel-default">
 		 <div class="panel-heading">
         		<ul class="mn_nav">
                 <li><span class="head">Thảo Luận</span></li>
            
             
              
            </ul>
            <div class="clearfix"></div>
         </div>
  		<div class="panel-body">
        
                                 <script>
			window.fbAsyncInit = function() {
 FB.init({appId: '<?php echo FB_ID;?>', status: true, cookie: true, xfbml: true});

     FB.Event.subscribe('comment.create', function(response) {
          var commentQuery = FB.Data.query('SELECT fromid, text FROM comment WHERE post_fbid=\'' + response.commentID + '\' AND object_id IN (SELECT comments_fbid FROM link_stat WHERE url=\'' + response.href + '\')');
      var user = FB.Data.query(
       "select name, id, url, pic_square from profile where id in"
     + "(select fromid from {0})", commentQuery);
 
  FB.Data.waitOn([commentQuery,user], function () {
   ct = commentQuery.value[0].text;
   u = user.value[0].name;
   td='<?php echo2($data['post']['title']) ?>';
   url='<?php echo url() ?>';
   m='truyen';
   ip='<?php echo get_ip(); ?>';
   id='<?php echo $_GET['id'] ?>';
	// Query get user info with fromid
	//Send data to server using ajax ------ KAKAKAKAKAKA
			 var   values='comment_user='+u+'&comment_tieude='+td+'&comment_url='+url+'&comment_type='+m+'&ip='+ip+'&comment_id='+id+
    '&comment_content='+ct+'&module=user&act=ajax&add_comment';
	
  	$.ajax({
      url: "index.php",
      type: "post",
      data: values,
      success: function(data){
          },
   
    }); 
	
    // Use your preferred way to inform the server to save comment
     });
 });         
 };
 
 </script>  
  			<!-- Truyen moi content -->
<div class="fb-comments" data-href="<?php echo url();?>" data-numposts="5" data-colorscheme="light"></div>
           <!-- End truyen moi content -->	
     
  
  		</div> <!-- End of panel body -->
		</div> <!-- End of panel -->

      
        
        


</div> <!-- COL MD 9 -->
  
                    <div class="col-md-4">
                    <div class="panel panel-default">
  		<div class="panel-body" style="padding:0px; margin:0px;">
  			
            <div class="row" itemscope="" itemtype="http://schema.org/Book">
             
     
                      
                    <div class="col-md-12 col-sm-12 col-xs-12" style="background-color:#fafafa;">
                  
                      <img src="http://localhost/anime24h.vn/images/upload/nzr6bry7mfkckw.jpg" class="pull-left img-circle" style="max-width:50px; margin:5px"/>
                      <h3 class="name" itemprop="name" style="padding-top:5px; padding-left:10px">Shingeki no Kyojin</h3>
                       
                      <!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>

<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-52206d695b0bc883"></script>
<!-- AddThis Button END -->
                        
                      <div class="clearfix"></div>
                                    <div class="item_truyen_detail" style="background-color:#fafafa; border-radius:5px; margin-top:10px">
                   
<ul class="nav nav-tabs" id="truyen_detail">
  <li class="active"><a href="#truyen_thongtin" data-toggle="tab">Thông Tin</a></li>
  <li><a href="#truyen_noidung" data-toggle="tab">Nội Dung</a></li>
   <li><a href="#truyen_tags" data-toggle="tab">Tags</a></li>


</ul>
<div style="height:5px"></div>
<div class="tab-content truyen_thongtin_tab">
  <div class="tab-pane fade in active" id="truyen_thongtin">
  <table class="table" id="truyen_detail_metadata">

                    		<tbody><tr>
                    			
                    		</tr>
                    		<tr>
                    			<td class="theloai" align="right">Thể Loại:</td>
                    			<td class="theloai"><a href="http://localhost/anime24h.vn/truyen/action.html"> <i class="fa fa-tags"></i> Action </a></td>
                    		</tr>
                    		<tr>
                    			<td class="tinhtrang" align="right">Tình Trạng:</td>
                    			<td class="tinhtrang"><span><a href="http://localhost/anime24h.vn/status/truyen-hoan-thanh.html">Full</a></span></td>
                    		</tr>
                            <tr>
                    			<td class="tinhtrang" align="right">Fansub</td>
                    			<td class="nguon"><span>Đang cập nhật ...</span></td>
                    		</tr>
                    		<tr>
                    			<td class="view" align="right">Lượt Xem:</td>
                    			<td class="view"><span class="badge">0</span></td>
                    		</tr>
                    			<tr>
                    			<td class="view" align="right">Số Ep</td>
                    			<td class="sochuong"><span class="badge">25 / 25</span></td>
                    		</tr>
                           
                    		<tr>
                    			<td class="stat_info" align="right">Đăng bởi:</td>
                    			<td class="stat_info"><span class="author"></span>  &nbsp;&nbsp;&nbsp;<span class="time"></span></td>
                    		</tr>
                    		<tr>
                    			<td class="stat_info2" align="right">Mới Nhất :</td>
                    			<td class="stat_info2">
                    				<span>
                    					<a href="index.php?module=truyen&amp;act=view_ep&amp;id=279">Episode 25</a>
                    				</span>
                    				</td>
                    		</tr>
                            <tr>
                    			<td class="stat_info2" align="right">Thời gian đăng</td>
                    			<td class="stat_info2">
                    				<span>
                    					1 tháng trước                    				</span>
                    				</td>
                    		</tr>
                             <tr>
                    			<td class="stat_info2" align="right">Thời gian cập nhật</td>
                    			<td class="stat_info2">
                    				<span>
                    					2 ngày trước                    				</span>
                    				</td>
                    		</tr>
                    	</tbody></table>
               
  </div>
  <div class="tab-pane fade" id="truyen_noidung"> 
   					 <div class="noidung" itemprop="description">
    					 <p>Eren Jaeger sống trong một thành phố được bao bọc bởi những bức tường cao chất ngất. Trong khi đó, ở bên ngoài, con người đang chống lại Titans. Trong nhiều thập kỉ, các thành viên của Scouting Legion là nhóm người duy nhất dám bỏ lại những bức tường an toàn đó để đi tìm thông tin về Titans. Mỗi khi nhóm họ trở về, rất nhiều người trong số đó đã chết. Tuy nhiên, Eren sẵn sàng gia nhập với họ để đổi lấy sự tự do.</p>                         
                         </div>
       </div>
  <div class="tab-pane fade" id="truyen_tags"> 
  <?php echo $data['ep']['data_tags']; ?>
  </div>
 
</div>
<script>
$('#truyen_detail').click(function (e) {
  	e.preventDefault();
  	 	if($(this).find('.active').find('a').attr('href') != '#truyen_noidung'){
  		  	if($('.noidung').height() > 150){
			$('.noidung').css('height', '140').css('overflow', 'hidden');
			$('.truyen_thongtin_tab').append('<p id="threedots" style="text-align:center; font-size: 15px;">...</p><p class="viewmore extend">Xem thêm</p>');
			
		}
  }else{
	$('#threedots').remove();
	$('.viewmore').remove();
	$('.noidung').css('height', '');
  }
		  
  	$(this).tab('show');
  
});

$('.item_truyen_detail .viewmore').live('click', function(e){
	if($(this).hasClass('shorten')){
		$('.noidung').css('height', '140').css('overflow', 'hidden');
		$(this).addClass('extend');
		$(this).html('Xem thêm');
		$(this).removeClass('shorten');
		$('#threedots').html('...');
		window.scroll(0,findPos(document.getElementById("truyen_detail")) - 50);
		
	}else{
		$('.noidung').css('height', 'auto');
		$(this).addClass('shorten');
		$(this).html('Rút gọn');
		$(this).removeClass('extend');
		$('#threedots').html('');
	}
});
</script>
             </div><!-- End item_truyen_box -->
                    </div> <!-- End of col-md-9 -->



   </div> <!-- End of row -->
 	</div> <!-- End of panel body -->
		</div> <!-- End of panel -->
        
                    
                    
  						<?php // truyen_render_theloai(); ?>
     	<!-- START Render TRUYEN View -->	<?php //truyen_render_view(); ?>	
 <!-- START RENDER video comment --> <?php //render_pick(); ?> <!-- End RENDER video comment --> 
 <!-- START RENDER video Xem Nhieu -->     <?php //blog_render_view(); ?>   <!-- end video xem nhieu -->


		



					</div> <!-- End col-md-3 right -->




	
	</div><!-- end row -->
</div><!-- end wrapMain -->
<div class="clearfix"></div>

<script type="text/javascript">
	$(document).ready(function(){
		$('.follow-story').live('click',function(e){
			e.preventDefault();
			username = '<?= $_SESSION['user']['username']; ?>';
			if(!username){
				window.location.href = '<?= LOGIN ?>';
				return;
			}
			truyen_id = '<?= $data['id']; ?>';
			username = '<?= $_SESSION['user']['username']; ?>';
			
			$.ajax({
				url: 'index.php?module=user&act=ajax&follow_story=1',
				type: 'POST',
				data: {truyen_id: truyen_id, username: username},
				success: function(data){
					if(data) newData = $.parseJSON(data);
					if(newData.error){
						popupMessage('Lỗi', [newData.error], 'alert-danger');
					}else if(newData.message){
						popupMessage('Thành công', [newData.message], 'alert-success');
					}
				},
			});
		});

		

		

		$('.pagination a').live('click', function(e){
			
			$('#wrap_chuong_table').append('<div class="loading" id="mainLoading"><div id="loadMoreItems" class="normalLoadBtn"><img width="20" src="public/images/loading.gif" alt="loading" /> Loading </div><div class="clr"></div></div>');
			window.scroll(0,findPos(document.getElementById("chuong_table")) - 50);
		});
	});
</script>